<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .con{
            width: 500px;
            border: 2px solid red;
            margin: 0 auto;
            overflow: hidden;
        }
        </style>
</head>
<body>
    <div class="con">
        <div class="item"> 
           <img src="images/animal1.png"/>
        </div>
        <div class="item"> 
         <img src="images/animal2.png"/>
        </div>
        <div class="item"> 
         <img src="images/animal3.png"/>
        </div>
     </div>
    
</body>
<script>
  var con =document.getElementById("con");
  var itemList = con .getElementsByClassName("item");
  for(var i =0;i<itemList.length;i++){
      itemList[i].onclick = function(){
        this.style.backgroundColor ="red";
    }
}

    </script>

</html>